package com.transaction.simulate.mapper;

import com.transaction.simulate.model.dto.FundRate;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

public interface FundRateMapper {

    List<FundRate> getFundRateList(FundRate fundRate);

    @Insert("insert into t_fundRate (channelCode,fundCode,startAmount,endAmount,indiOrInst,fundRate) " +
            "values (#{channelCode},#{fundCode},#{startAmount},#{endAmount},#{indiOrInst},#{fundRate})")
    void addFundRate(FundRate fundRate);

    void deleteFundRate(FundRate fundRate);

    @Select("SELECT * FROM t_fundRate t " +
            "WHERE t.channelCode = #{channelCode} " +
            "AND t.fundCode = #{fundCode} " +
            "AND t.startAmount <= #{applicationAmount} " +
            "AND t.endAmount > #{applicationAmount} ")
    FundRate selectFundRateByChannelFundAndAmount(@Param("channelCode") String channelCode,
                                                  @Param("fundCode") String fundCode,
                                                  @Param("applicationAmount") BigDecimal applicationAmount);
}
